package com.mh.study.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author meng.han
 * @since 2022-03-22
 */
@RestController
@RequestMapping("/config")
@RefreshScope
public class CloudConfigController {

    @Value("${animal.dog.color}")
    private String color;

    @Value("${animal.dog.gender}")
    private String gender;

    @GetMapping("/view")
    public Map<String, String> view(){
        return Map.of("dog", color + "-" + gender);
    }

}
